/**
 * miniPaint - https://github.com/viliusle/miniPaint
 * author: Vilius L.
 */

//css
import './../css/reset.css';
import './../css/utility.css';
import './../css/component.css';
import './../css/layout.css';
import './../css/menu.css';
import './../css/print.css';
import './../../node_modules/alertifyjs/build/css/alertify.min.css';
import './../css/antd-polyfill.css'

//js
import app from './app.js';
import config from './config.js';
import './core/components/index.js';
import Base_gui_class from './core/base-gui.js';
import Base_layers_class from './core/base-layers.js';
import Base_tools_class from './core/base-tools.js';
import Base_state_class from './core/base-state.js';
import File_open_class from './modules/file/open.js';
import File_save_class from './modules/file/save.js';
import * as Actions from './actions/index.js';

window.addEventListener('load', function (e) {
	// Initiate app
	var Layers = new Base_layers_class();
	var Base_tools = new Base_tools_class(true);
	var GUI = new Base_gui_class();
	var Base_state = new Base_state_class();
	var File_open = new File_open_class();
	var File_save = new File_save_class();

	// Register singletons in app module
	app.Actions = Actions;
	app.Config = config;
	app.FileOpen = File_open;
	app.FileSave = File_save;
	app.GUI = GUI;
	app.Layers = Layers;
	app.State = Base_state;
	app.Tools = Base_tools;

	// Register as global for quick or external access
	window.Layers = Layers;
	window.AppConfig = config;
	window.State = Base_state;
	window.FileOpen = File_open;
	window.FileSave = File_save;
	window.GUI = GUI;

	// Render all
	GUI.init();
	Layers.init();


	


	// 测试
	var imageList = [
		{
			name: '噪点侧视图.jpg',
			url: 'https://img0.baidu.com/it/u=327810286,1318266794&fm=253&fmt=auto&app=138&f=JPEG?w=750&h=500'
		},
		{
			name: '小米su7-2.jpg',
			url: 'https://img.pcauto.com.cn/images/ttauto/2024/03/15/7346019478687236618/03c608930a36434abd87f3d6ccd89d00~noop.image.png?x-expires=1713046740&x-signature=QJXG%2FoQhzJAm6eH%2B32jBhDNsCUM%3D'
		},
		{
			name: '人像-3.webp',
			url: 'https://gw.alipayobjects.com/zos/antfincdn/LlvErxo8H9/photo-1503185912284-5271ff81b9a8.webp',
		},
		{
			name: '世界顶级汽车精选桌面高清壁纸高清大图预览-4.jpg',
			url: 'https://img1.baidu.com/it/u=2648999282,2412231060&fm=253&fmt=auto&app=138&f=JPEG?w=1422&h=800',
		},
		{
			name: '[4k动态壁纸]艾雅法拉火山旅梦-5.jpg',
			url: 'https://img1.baidu.com/it/u=1088151449,983906005&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500',
		},
		{
			name: '档案 111',
			url: '../../img/image.png',
		},
		{
			name: '档案 222',
			url: '../../img/5-4-001.jpg',
		},
	];
	var imageIndex = 6;

	if (process.env.NODE_ENV !== 'production') {
		GUI.GUI_navigate.start({
			index: imageIndex,
			count: imageList.length,
			name: imageList[imageIndex].name,
			url: imageList[imageIndex].url,
			onPrev: (index, loadImage) => {
				var imageItem = imageList[index] || {};
				loadImage(imageItem.name, imageItem.url)
				console.log('1', index);
			},
			onNext: (index, loadImage) => {
				var imageItem = imageList[index] || {};
				loadImage(imageItem.name, imageItem.url)
				console.log('2', index);
			},
			onSave: () => {
				console.log(1111111111111);
			}
		})
	}

}, false);
